package com.xin.springclouduser.converter;

import com.xin.springclouduser.dataobject.User;
import com.xin.springclouduser.dto.UserDTO;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

public class User2UserDTO {
    public static UserDTO convert(User user){
        UserDTO userDTO=new UserDTO();
        BeanUtils.copyProperties(user,userDTO);
        return userDTO;
    }
    public static List<UserDTO> convert(List<User> users){
        return users.stream().map(e->convert(e)).collect(Collectors.toList());
    }

}
